/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package program.gui;

import java.awt.BorderLayout;
import java.awt.Image;
import java.io.File;
import java.io.FileFilter;
import java.io.IOException;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.imageio.ImageIO;
import javax.swing.ImageIcon;
import javax.swing.JFileChooser;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.filechooser.FileNameExtensionFilter;
import program.bl.PDFViewerController;
import program.utilities.ImageRotator;
import program.utilities.ImageUtilities;
import program.utilities.PDFUtilities;

/**
 *
 * Responsible: Patrick, Bernhard
 */
/**
 * Functionality: 1. proof if user wants to choose a bill which alread exists in
 * PDF 1.1.) if he wants to youse PDF, display the PDF, so he can check it 2.
 * create a new bill 2.1) display a dlg so that the user can scan or choose
 * images to create a new bill 2.1.1 : call a program to scan a picture 2.1.2 :
 * show jfilechooser to select an existing page 2.2 : user can change the order
 * of the pages, by showing an contextmenu when he clicks on a page 2.3 : user
 * can change the direction of the picture 2.4 : user can delte one page
 */
public class ViewCopyDlg extends javax.swing.JDialog {

    private ThumbnailPanel tp;
    private PDFViewerController pdfvc = PDFViewerController.getInstance();
    private File finishedPDF;
    private boolean ok;

    /**
     * Creates new form CreateBillDlg
     */
    public ViewCopyDlg(java.awt.Frame parent, boolean modal, File pdf) {
        super(parent, modal);
        initComponents();
        tp = new ThumbnailPanel(ThumbnailPanel.ORDER_HORIZONTAL, center);
        try {
            if(pdf != null)
            {
                System.out.println("VCD: " + pdf.getPath());
                pdfvc.setPages(pdf);
            }
            south.add(tp, BorderLayout.CENTER);
            tp.draw();
        } catch (Exception ex) {
                        JOptionPane.showMessageDialog(null, ex);

        }
        pack();
        setLocationRelativeTo(parent);
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {
        java.awt.GridBagConstraints gridBagConstraints;

        south = new javax.swing.JPanel();
        jScrollPane1 = new javax.swing.JScrollPane();
        center = new javax.swing.JPanel();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);

        south.setLayout(new java.awt.BorderLayout());
        getContentPane().add(south, java.awt.BorderLayout.PAGE_END);

        javax.swing.GroupLayout centerLayout = new javax.swing.GroupLayout(center);
        center.setLayout(centerLayout);
        centerLayout.setHorizontalGroup(
            centerLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 398, Short.MAX_VALUE)
        );
        centerLayout.setVerticalGroup(
            centerLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 298, Short.MAX_VALUE)
        );

        jScrollPane1.setViewportView(center);

        getContentPane().add(jScrollPane1, java.awt.BorderLayout.CENTER);

        pack();
    }// </editor-fold>//GEN-END:initComponents



    private void updateMainPanel(Image img) {
        center.removeAll();
        if (img != null) {
            center.add(new JLabel(new ImageIcon(img)));
        }
        center.updateUI();
    }

    public File getFinishedPDF() {
        return finishedPDF;
    }

    public boolean isOk() {
        return ok;
    }
    
    

    /**
     * @param args the command line arguments
     */

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JPanel center;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JPanel south;
    // End of variables declaration//GEN-END:variables
}
